<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.util.collection.iterator.FilteringIterator</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.util.collection.iterator.FilteringIterator");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327">tango.util.collection.iterator.FilteringIterator</a></h1>
                
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L51">FilteringIterator</a></span>
<script>explorer.outline.addDecl('FilteringIterator');</script>(T) : Iterator!(T);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">FilteringIterators allow you to filter out elements from
 other enumerations before they are seen by their `consumers'
 &#40;i.e., the callers of `get'&#41;.</font><br><br>
<font color="black">FilteringIterators work as wrappers around other Iterators.
 To build one, you need an existing Iterator &#40;perhaps one
 from coll.elements&#40;&#41;, for some Collection coll&#41;, and a Predicate
 object &#40;i.e., implementing interface Predicate&#41;. 
 For example, if you want to screen out everything but Panel
 objects from a collection coll that might hold things other than Panels,
 write something of the form:
 <pre class="d_code">

 <span class="i">Iterator</span> <span class="i">e</span> = <span class="i">coll</span>.<span class="i">elements</span>();
 <span class="i">Iterator</span> <span class="i">panels</span> = <span class="i">FilteringIterator</span>(<span class="i">e</span>, <span class="i">IsPanel</span>);
 <span class="k">while</span> (<span class="i">panels</span>.<span class="i">more</span>())
  <span class="i">doSomethingWith</span>(<span class="k">cast</span>(<span class="i">Panel</span>)(<span class="i">panels</span>.<span class="i">get</span>()));
 
</pre>
 To use this, you will also need to write a little class of the form:
 <pre class="d_code">

 <span class="k">class</span> <span class="i">IsPanel</span> : <span class="i">Predicate</span> {
  <span class="k">bool</span> <span class="i">predicate</span>(<span class="i">Object</span> <span class="i">v</span>) { <span class="k">return</span> <span class="k">cast</span>(<span class="i">Panel</span>) <span class="i">v</span> !<span class="k">is</span> <span class="k">null</span>; }
 }
 
</pre>
 </font><br><br>
<b>See Also:</b><br>
tango.util.collection.Predicate.predicate<br><br>
<b>author:</b><br>Doug Lea<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Iterator!(T) <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L61">src_</a></span>
<script>explorer.outline.addDecl('src_');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">The enumeration we are wrapping
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Predicate <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L67">pred_</a></span>
<script>explorer.outline.addDecl('pred_');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">The screening predicate
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L73">sign_</a></span>
<script>explorer.outline.addDecl('sign_');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">The sense of the predicate. False means to invert
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L79">get_</a></span>
<script>explorer.outline.addDecl('get_');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">The next element to hand out
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L85">haveNext_</a></span>
<script>explorer.outline.addDecl('haveNext_');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">True if we have a next element 
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L92">this</a></span>
<script>explorer.outline.addDecl('this');</script>(Iterator!(T) <span class="funcparam">src</span>, Predicate <span class="funcparam">p</span>); [public]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Make a Filter using src for the elements, and p as the screener,
 selecting only those elements of src for which p is true
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L103">this</a></span>
<script>explorer.outline.addDecl('this');</script>(Iterator!(T) <span class="funcparam">src</span>, Predicate <span class="funcparam">p</span>, bool <span class="funcparam">sense</span>); [public]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Make a Filter using src for the elements, and p as the screener,
 selecting only those elements of src for which p.predicate&#40;v&#41; == sense.
 A value of true for sense selects only values for which p.predicate
 is true. A value of false selects only those for which it is false.
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L115">more</a></span>
<script>explorer.outline.addDecl('more');</script>(); [public, final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Implements tango.util.collection.model.Iterator.more
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L123">get</a></span>
<script>explorer.outline.addDecl('get');</script>(); [public, final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Implements tango.util.collection.model.Iterator.get.
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/collection/iterator/FilteringIterator.d?rev=3327#L153">findNext</a></span>
<script>explorer.outline.addDecl('findNext');</script>(); [private, final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Traverse through src_ elements finding one passing predicate
</font><br><br></dd></dl>
<script>explorer.outline.decSymbolLevel();</script></dd></dl>
<script>explorer.outline.decSymbolLevel();</script></td></tr>
                <tr><td id="docfooter">
                         :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Tue Mar  4 22:45:34 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>